package com.cip.admin.dao.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.cip.admin.dao.SMSDAO;
import com.cip.admin.model.Sms;
import com.cip.admin.model.User;
import com.cip.admin.dao.impl.CipHibernateDAOSupport;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

public class SMSDAOImpl  extends CipHibernateDAOSupport implements SMSDAO{

	
	/**
	 * 
	 */
	public void bulkUpdateSMS(List<Sms> smsList) throws Exception {
		getHibernateTemplate().saveOrUpdateAll(smsList);
	}
	
	/**
	 * 
	 */
	public List<User> getAllUsers()throws Exception {
		HibernateTemplate hibernateTemplate = getCipHibernateTemplate();	
		System.out.println("update==");
	    List<User> user = hibernateTemplate.loadAll(User.class);
		return user;
	}	
	
	/**
	 * 
	 */
	public List<User> broadcastSmsSelect(Map<String,String> broadcastSmsSelect)throws Exception {
		
		String query="select user from User as user where user.classYear='"+broadcastSmsSelect.get("classYear")+"'"
				+"and user.section='"+broadcastSmsSelect.get("section")+"'";
		
		List<User> user = getCipHibernateTemplate().find(query);
		
		return user;
	}

}
